﻿namespace Devonline.Entity;

/// <summary>
/// 货运单, 字符串表达式的默认实现
/// </summary>
[DisplayName("货运单")]
public class TransportViewModel : TransportViewModel<string>, IViewModel, IEntitySet
{
    /// <summary>
    /// 通用附件集合, NotMapped Attachments 用于记录实体对象上上传的附件
    /// </summary>
    [NotMapped]
    public virtual ICollection<Attachment>? Attachments { get; set; }
}

/// <summary>
/// 货运单
/// </summary>
/// <typeparam name="TKey"></typeparam>
[DisplayName("货运单")]
public abstract class TransportViewModel<TKey> : ViewModel<TKey>, IViewModel<TKey>, IEntitySet<TKey> where TKey : IConvertible
{
    /// <summary>
    /// 运单号
    /// </summary>
    [DisplayName("运单号"), Required, MaxLength(36)]
    public virtual string Code { get; set; } = null!;
    /// <summary>
    /// 运费
    /// </summary>
    [DisplayName("运费"), Excel]
    public virtual decimal Freight { get; set; }
    /// <summary>
    /// 发货时间
    /// </summary>
    [DisplayName("发货时间"), Excel]
    public virtual DateTime? ShippingTime { get; set; }
    /// <summary>
    /// 到货时间
    /// </summary>
    [DisplayName("到货时间"), Excel]
    public virtual DateTime? DeliverTime { get; set; }

    /// <summary>
    /// 报价方式
    /// </summary>
    [Column("offer_type"), DisplayName("报价方式"), MaxLength(16), Excel]
    public virtual string? OfferType { get; set; }
    /// <summary>
    /// 起运港, 来自基础数据起运港配置项, 默认: 宁波
    /// </summary>
    [Column("ship_port"), DisplayName("起运港"), MaxLength(128), Excel]
    public virtual string? ShipPort { get; set; }
    /// <summary>
    /// 到达港
    /// </summary>
    [Column("arrive_port"), DisplayName("到达港"), MaxLength(128), Excel]
    public virtual string? ArrivePort { get; set; }

    /// <summary>
    /// 装柜时间
    /// </summary>
    [DisplayName("装柜时间"), Excel]
    public virtual DateTime? LoadContainerTime { get; set; }
    /// <summary>
    /// 离港时间
    /// </summary>
    [DisplayName("离港时间"), Excel]
    public virtual DateTime? LeavePortTime { get; set; }
    /// <summary>
    /// 到港时间, 到达客户港口时间
    /// </summary>
    [DisplayName("到港时间"), Excel]
    public virtual DateTime? ArrivePortTime { get; set; }
    /// <summary>
    /// 放单时间
    /// </summary>
    [DisplayName("放单时间"), Excel]
    public virtual DateTime? ReleaseTime { get; set; }
}
